<?php

use yii\helpers\Url;

$web = Url::base();
?>

<link href="<?= $web ?>/css/frame.css" rel="stylesheet">

<div class="panel">
    <div class="panel-heading">订单信息</div>
    <div class="panel-body">
        <div class="form-horizontal">
            <div class="form-group">
                <label class="col-md-1 form-label-key">订单编号:</label>
                <label class="col-md-3 form-label-value"><?= $item['code'] ?></label>
                <label class="col-sm-2 form-label-key">订单总金额:</label>
                <label class="col-md-2 form-label-value">￥<?= $item['total_selling_price'] ?></label>
                <label class="col-md-1 form-label-key">所属机构:</label>
                <label class="col-md-2 form-label-value"><?= $item['institution_name'] ?></label>
            </div>
            <div class="form-group">
                <label class="col-md-1 form-label-key">下单用户:</label>
                <label class="col-md-3 form-label-value"><?= $item['user_name'] ?></label>
                <label class="col-sm-2 form-label-key">支付积分:</label>
                <label class="col-md-2 form-label-value"><?= $item['integral'] ?></label>
                <label class="col-md-1 form-label-key">支付备注:</label>
                <label class="col-md-2 form-label-value"><?= $item['pay_remark'] ?></label>
            </div>
            <div class="form-group">
                <label class="col-md-1 form-label-key">订单状态:</label>
                <label class="col-md-3 form-label-value"><?= $item['status_name'] ?></label>
                <label class="col-sm-1 form-label-key">下单时间:</label>
                <label class="col-md-2 form-label-value"><?= $item['create_datetime'] ?></label>
                <label class="col-md-1 form-label-key">备注:</label>
                <label class="col-md-2 form-label-value"><?= $item['remark'] ?></label>
            </div>
            <div class="form-group">
                <label class="col-md-1 form-label-key">身份证姓名:</label>
                <label class="col-md-3 form-label-value"><?= $item['idcard_name'] ?></label>
                <label class="col-md-1 form-label-key">身份证号码:</label>
                <label class="col-md-3 form-label-value"><?= $item['idcard_number'] ?></label>
            </div>
        </div>
    </div>
</div>
<div class="panel">
    <div class="panel-heading">商品信息</div>
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-bordered table-hover table-condensed">
                <thead class="nowrap">
                <tr>
                    <th>商品编号</th>
                    <th>商品名称</th>
                    <th>是否跨境</th>
                    <th>销售单价</th>
                    <th>购买数量</th>
                    <th>总金额</th>
                </tr>
                </thead>
                <tbody>
                <?php
                foreach ($item['goods_list'] as $goodsItem) {
                    ?>
                    <tr>
                        <td><?= $goodsItem['goods_code'] ?></td>
                        <td><?= $goodsItem['goods_name'] ?></td>
                        <td><?= $goodsItem['is_crossborder'] == 1 ? '是' : '否' ?></td>
                        <td>￥<?= $goodsItem['selling_price'] ?></td>
                        <td> <?= $goodsItem['quantity'] ?></td>
                        <td>￥<?= $goodsItem['selling_price'] * $goodsItem['quantity'] ?></td>
                    </tr>
                    <?php
                }
                ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="panel">
    <div class="panel-heading">收货信息</div>
    <div class="panel-body">
        <div class="form-horizontal">
            <div class="form-group">
                <label class="col-sm-2 form-label-key">收货人:</label>
                <label class="col-md-1 form-label-value"><?= $item['receiver_name'] ?></label>
                <label class="col-sm-2 form-label-key">电话:</label>
                <label class="col-sm-2 form-label-value"><?= $item['receiver_phone'] ?></label>
                <label class="col-sm-2 form-label-key">收货地址:</label>
                <label
                    class="col-md-6 form-label-value"><?= $item['receiver_province'] . $item['receiver_city'] . $item['receiver_region'] . $item['receiver_address'] ?></label>
            </div>
            <div class="form-group">
                <label class="col-sm-2 form-label-key">收货备注:</label>
                <label class="col-sm-10 form-label-value"><?= $item['receiver_remark'] ?></label>
            </div>
        </div>
    </div>
</div>
<div class="panel">
    <div class="panel-heading">配送信息</div>
    <?php
    foreach ($order_delivery_items as $order_delivery_item) {
        ?>
        <div class="panel-body">
            <div class="form-horizontal">
                <div class="form-group">
                    <label class="col-md-1 form-label-key">配送单号:</label>
                    <label class="col-md-2 form-label-value"><?= $order_delivery_item['boss_code'] ?></label>
                    <label class="col-md-1 form-label-key">物流公司:</label>
                    <label class="col-md-2 form-label-value"><?= $order_delivery_item['logistics_company'] ?></label>
                    <label class="col-md-1 form-label-key">快递单号:</label>
                    <div class="col-md-4">
                        <label class="form-label-value"><?= $order_delivery_item['logistics_code'] ?></label>
                        <a class="btn btn-default btn-get-logistics"
                           data-logistics-code="<?= $order_delivery_item['logistics_code'] ?>">查询物流
                        </a>
                        <div class="logistics-frame popover fade bottom in"
                             style="top: 40px; left: 20px; display: none;">
                            <div class="arrow"></div>
                            <div class="popover-title"><?= $order_delivery_item['logistics_code'] ?></div>
                            <div class="popover-content">
                                <div class="flow-line">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-condensed">
                    <thead class="nowrap">
                    <tr>
                        <th> 商品编号</th>
                        <th> 商品名称</th>
                        <th> 数量</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php
                    foreach ($order_delivery_item['goods_list'] as $goodsItem) {
                        ?>
                        <tr>
                            <td><?= $goodsItem['goods_code'] ?></td>
                            <td><?= $goodsItem['goods_name'] ?></td>
                            <td> <?= $goodsItem['quantity'] ?></td>
                        </tr>
                        <?php
                    }
                    ?>
                    </tbody>
                </table>
            </div>
        </div>
        <?php
    }
    ?>
</div>
<?php
if (count($backGoodsItems) > 0) {
    ?>
    <div class="panel">
        <div class="panel-heading">退货信息</div>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-condensed">
                    <thead class="nowrap">
                    <tr>
                        <th>商品编号</th>
                        <th>商品名称</th>
                        <th>销售单价</th>
                        <th>退货数量</th>
                        <th>返回积分</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php
                    foreach ($backGoodsItems as $backGoodsItem) {
                        ?>
                        <tr>
                            <td><?= $backGoodsItem['goods_code'] ?></td>
                            <td><?= $backGoodsItem['goods_name'] ?></td>
                            <td>￥<?= $backGoodsItem['selling_price'] ?></td>
                            <td> <?= $backGoodsItem['quantity'] ?></td>
                            <td><?= $backGoodsItem['selling_price'] * $backGoodsItem['quantity'] ?></td>
                        </tr>
                        <?php
                    }
                    ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <?php
}
?>
<script type="application/javascript">
    $(function () {
        $('.btn-get-logistics').click(function () {
            if ($(this).hasClass('btn-primary')) {
                $(this).removeClass('btn-primary');
                $(this).parent().find('.logistics-frame').hide();
            } else {
                $(this).addClass('btn-primary');
                $(this).parent().find('.logistics-frame').show();
                var container = $(this).parent().find('.flow-line');
                var logisticsCode = $(this).data('logistics-code');
                requestJson('get-logistics-handler', {logistics_code: logisticsCode}, true, function (responseData) {
                    if (responseData.status == 0 && responseData.data != null) {
                        container.html('');
                        $(responseData.data).each(function () {
                            var item = $(
                                '<article class="flow-line-item ">' +
                                '<div class="flow-line-desk">' +
                                '<div class="panel">' +
                                '<div class="panel-body">' +
                                '<span class="arrow"></span>' +
                                '<span class="flow-line-icon"></span>' +
                                '<p class="flow-line-date">' + this.time + '</p>' +
                                '<p class="flow-line-status">' + this.status + '</p>' +
                                '</div>' +
                                '</div>' +
                                '</div>' +
                                '</article>');
                            $(container).append(item);
                        });
                    }
                });
            }
        });
    });
</script>
